package com.jinyi.wwdeng.ui.main.adapter

import android.annotation.SuppressLint
import android.view.View
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.jinyi.lib_baseadapter.BGARecyclerViewAdapter
import com.jinyi.lib_baseadapter.BGAViewHolderHelper
import com.jinyi.wwdeng.R
import org.json.JSONObject

/**
 * JinYiTest
 * @Author wwdeng
 * @CreateTime: 2024/4/24 14:42
 * @Annotation：贷款申请适配器
 */
class CreditApplyLableAdapter(recyclerView: RecyclerView?) :
    BGARecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_credit_apply_lable) {
    override fun setItemChildListener(helper: BGAViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    @SuppressLint("SetTextI18n")
    override fun fillData(helper: BGAViewHolderHelper, position: Int, model: JSONObject) {
        val tvTitle = helper.getTextView(R.id.tvTitle)
        tvTitle.text = model.optString("showName")

        val tvValue = helper.getTextView(R.id.tvValue)
        tvValue.text = model.optString("showDetail")
        if (model.has("title") && model.optString("title") == "YES") {
            tvTitle.setTextColor(ContextCompat.getColor(mContext, com.jinyi.lib_base.R.color.color_000000))
            helper.setVisibility(R.id.vLine, View.VISIBLE)
        } else {
            tvTitle.setTextColor(ContextCompat.getColor(mContext, R.color.color_b6babc))
            helper.setVisibility(R.id.vLine, View.INVISIBLE)
        }
    }
}